added 404 and 500 error handling