working recursive prg