Remove code duplication in view helper

instanceof should be sufficient?