fixed if block bug