Fixed missing  endif bug