optimized code for select.html