clarified evaluation function with comments (i hope)