refactored for greater clarity