refactoring for clarity and simplification