refactror and documenting