refactoring into classes