Attempt to fix query issue with postgres