cd function improve