scripts/channels: refactored a bit