now without endless loop