You're already using /sockmark, so just add $chan to that. You should understand the code you're running.