fixed major bug in the chain() method