update eval function, a smarter version