Clean up code, add logic for non-repeating items