refactored if/else in census index to the controller