implements cd (closes #23)