Many thanks to Valery, Andrej and Richard. So far, collectterms(%,x) worked best for me, but I see there are many other possibilities. Thanks again for solving my problem Eli