shape: use a better loop condition