added server side error handling