Done code cleanup to avoid return statement in recursive functions