cleanup/refactoring of evaluation code