before suming function