Bug fix in toId()