move the codes to run in ui thread