fix closing if in template