Conditional increment of variable