Server code almost working