change cart algorithm