Why do you need return `undefined` here? I think my code will return the same result as your.