Added cd error checking