Removed recursive implementation