added custom trend error function implementation