Moved the listener logic to worker. Refactoring.