Fix logic error in FirstInChain handling