Refacroting: All test cases working OK