Turned program into a function