cleaning up complexity in pages controller