Fixed db access bug