refactors parseData function