Improve loop implementation.