implemented thread for scanning and for search_max, needs enormous amount of RAM, needs to be fixed