Accepted, some refactoring