refactored for readability