Rewrite evaluate function