Implementing autoSelectView() function