Bug fix in expand string