fixed the if bug