made some work on the second problem