moved thread logic to services