script update

+ switch log write to a function
+ add new variable ($log_step)