huge refactor - correct code for parser not working