Fixing $index property check