refactoring for better organization