optimised code

added more d’s too - some fixes still to make.