using co-recursive for all optimization