Loop implementation.