refactoring for performance