Simplified version (still DRY)