This is now the base function and everything else called from here.