refactoring into indepentent classes