trying to compactify view code