implement save program function