Extract indexes to index module
Simplify conditional expression