New database query and little adjustment for the previous commit.