Made changes to make sure socket events are not bound more than once