Fixed variable scope issues with 'select' filtering