Changed structure of icon selector function

Fixed scope of iconClass and restructured the icon functions.