tasks 1-3 from ex 9 implemented