ex5

* faster implementation not commited yet