optimised the code by adding selectedIndex method on select box