delete items and refactoring code