adding elements recursively