fixing pg handling