change the program to a function