Refactor to extract parsing out code blocks