corrected viewporter function