Fix serious endif bug