Passed all tests and refactored code