decompose program to function