Adjust padding loop so n.length is called only once
Add spacing and comments
Formatting consistency