refactor led selection code