Fixed db functions