Update chain.py

bug fixed