include max_derivation value in distance check