Added try and catchs to the server so no error will occur