Fixed substitute bug