Changed parser to a function