recursive algorithm for subdivision working