This function is also tail-recursive, so please add [tailRecursive] annotation.