Fix bad end/if position

Fixes #1