Cleaned up selection.lua to be more readable and consistent