refactored index code, dealing with merge conflicts