Rewrote filter and map functions for lazy evaluation.