fixed chain bug which #13 pointed out