Fixed errors in both questions - coding done