separated code for client and server