loop was wrong