Generalised confounding with Groebner bases