Updated with few functionality and corresponding test cases.