Error in add function. Edited