less ugly loop