Fix: turning on database in the thread