moved expandt3x code to own function