use enumerate (suggested by @larsmans)