refactored viewport item handling