refactoring + little improvements