implement map, flatMap, filter in terms of for
use flatmap and filter instead of for
better comments