move parsing logic to build_parser function for testing