Improved the DP version