added in a catch for thrown errors in side of function so that we can unmeck some modules