#729 - clean up nasty loop