changed socket code; made it working