splitting up server and client code