solution to 1st 2 problems