implemented solution to 500 status code