Refactored a part of the parsing routine