implemented add function