Fixed db bug
Working out pg bug