fixed else if bug