Remove code duplication in view helper

confirm