fixing else if bug