addd error handing in server code