fixed mistake in reimplementation of cdr