refactoring some stuff