Refactored Code and Add additional Unit Test