updated lsqEndTerm to only be a function of x