Put back trial loop in ply_query