updated the comment for flatten
implemented take and takewhile