refactoring for best practices