added null chk for 500 error