implemented structure for task3, key C and D working