fixed some loops