Beginning of evaluation function