refactored the setupItem code