started rewrite of cart functions