changed order of postgres function