fix multiple loops