Uses loop instead of do. And fixes the padding for length.