splitting code apart so core can focus on being main