more recusion improvments