rewrite eval function