adding custom error handler for 404 and 500 codes