need to fix this so database thread runs continuously