Corrected bug and added parseInt()

Oh, JS, you silly!