right query constraint, hard coded pg offsets --- need to xml input