add is_not_empty and is_empty functions.
change interface of function called by for_each_