DRYed up view code a bit