solving a recursion problem on sincronization