Refactored the parsing a bit