refactor for flexibility in view loading