Fixed db bug properly