cleaned up server, added some validation