rewrite for lazy evaluation