modify loop condition.eliminate some unecessary computing.