restructure and fix threading refresh issue