removed unnecessary variable and minor tweaks in atoi function