implement a function for recursive evaluation