implement script serialization