refactoring completed cart code