moved where the relay thread is being called