removing duplicate code from Parser::parseDynamic