Avoid recursive calls as much as possible.