fixed bug where substitute failed