Separate stage's vieport code into a method