fixed bug in background thread