Fixed a bug. 
should be called only when DP is null.