fixed nasty loop when shared = true