move parser methods into a parser class in lib directory