Moved index controller logic to better place