Worked out a var-selection routine