Added variable to reduce calculations of integer division in other loop of OptimalSize().