Cut the add function into smaller procedures.