Tidying up JS code.

Adding more variables and ++ as opposed to + 1