Fix 'end' block bug