refactored cart script