Remove an incorrect if statement condition from the code to find an appropriate index for the position arrays.