I would really like to make this function bit shorter and move binding to socket functionality to other function.