added proper error handling on server