extracted view logic to helper

plus miscellaneous cleanup