Fixed error 500 when it should be 404