Reorganize code for variable selection