Refactoring as requested by @bgentry