added working solution for problem 1