refactored client listener