implementing the recursive framework and it is working!