Update parser.js

Moved in a separate function.
Tried to fix sneaky tabs and spaces.