Refactored and passed all tests. Further refactoring required