refactoring into struct methods