fixed if/then/else bug