Solved first two problems