added code to compute dspm on the fly