refactoring for better understanding