config block should be a variable and passed into the functions so its not duplicated (at least it looks duplicated to me)