add item, some refactoring