implementation of parser