modified the way socket handles communications