refactored random item code