refactoring + bug fix