Added method to determine optimal size