Refactoring select.lua;