Added Code for both functions