add stolen code from Ians config