refactoring the parsing method