Extracted add function.
Merge pull request #1 from astery/master

Extract add function.