add extent function by recursion