Fiddled with code. Inexplicably now works