attempt to fix borked commit acd7e7a8ae089210fe2c1415af8ed1766747caad which duplicated lots of code