removed unused functions. Folded in doc element to loop and added to data set