fix infinity recursive call