Move startup functionality to a function