Added best-contrast function