updated algorithm for math on 'Add' function