refactor parser a bit