refactoring + cleanup