Added error checking in server