database debug almost done