Solution to problem 1 & 2