add chain
use util.chain and imap in greedy