added new 500 error logic