fix and extract retract logic rework infer_hand logic