refactored server, added basic functionality