solves part I