first working prototype. Does not recurse