cleaning and documenting functions