fix return in generator function, add examples.