Changed to using server, reformatted code