merge with server code