nested if inside of a repeat