optimized code add to inventory