Extracted add function.