server side solution:adding error handling