added parentheses
Corrected currPosition logic