move pk helper to query