up to problem 2 - used some helper f# functions