fix the portid query