Fixed a bug that resulted in multiple ifs with same index