Added extra error handling for handling invalid views.