Minor improvement to substitute