solving problems with letrec