Refactors view manager handling into helper function.