inventory update, code refactoring