Added Code and Test Cases