refactoring to decrease file size