Fixing bug on the listen method for server