removed some code duplication in the parsing function