fix variant 2 and variant 3 logic