some refactoring of manipulate