Added solution to second problem