ToIndex on objects. Refactored bad code out of controller.