start rewrite of script in C