Rationalising ddoc function