Refactor index controlling (using events)