fix recursive functions