refactor fragile parsing method