Fixing diameter function