Updated the view loading logic to be more flexible.