Add and refactor functions