cleaned my loop code