moved unlock in the server code