modified dynamic progming filr