Improved parseInt implementation