refactor viewport interaction functions