Quick refactor of view code