Extract main code to its own object