cleaned up loops