adding decay terms to cost J