Refactor the code.
Update test cases.