Updated to use PyQuery