implemented take and takewhile