moved some views for readability
reduced code duplication and improved performance