refactored some of the pad code to make it more concise.