refactoring и fixes