fixed if cycle error