fixed some bugs on the server side