feat(main.js): created a variable for $selected length for performance