Refactored - moved variable += 1 to same line as 'if' statement and removed extra 'end'