update the cd function