changed 404 handling to properly throw an exception