cleaned up the code and moved scrollToSelection to markFound