refactor to record and protocol
merge
fix bug of new API record
allow to run task for multiple times