Extracted setup functions from closures to functions