add record function

fix script bug issue
fix lock issue