Opened database for new thread, this was possibly causing a little bug