Moved to a global and local function for after and before execution.