functionize the program