revised SDM script