reduce code size

delete unreferenced var i, and reduce the code in if condition
Merge pull request #608 from Lellansin/master

reduce code size