fixed cd-wrapper function