fixed if loop