copied some sanityinc stuff