Refactored 47 and added test cases.