minor revision
remove lazy eval, and minor memory footprint
merge while loop together