Making some improvements 
- fixing a problem with the logic of code
- removing parseInt

Still generates runtime error