Working version of server2 code