Refactored code. Added more test cases for others category