fixed database read bug and added debugging output