Replace the distance-to-probability method; Keep refactoring codes;