made helperfunction in dataFunctions

So much code looked alike, now tried to put into dataFunctions. step 1