Refactor home page filtering in pages_controller

Big oops. Fixed now.