works when recusion doesnt reach its limit