updated fix for dsc-504.
code tidy up.