refactoring into smaller chunks