improvements to addItem alg