more improvements to db functions