fix if statement issue with boolean indexing