enhanced print error + prepare handeling cmd + reset NULL buffer and tmp_buffer