refactored for simplification