Added contingency to turning code. May or may not work properly.