Made the evaluation function. Some utility functions left to do