Problem 2&3 Solution