more robust square_off