refactored for cleanliness/clarity