Abstract remove and render of views into a function