fix if condition for the 3rd time