ex9 with small fixes