refactored for improved clarity