first part of the server re-implemented