added determinemaxdiameter