db initial queries bug fix