Refactored setItems method