fixed changing UI in background thread error, code organization