Use a common function for each method.
Merge pull request #2 from ben-eb/extract-methods

Use a common function for each method.
Minor tweaks