new API for record; add unittest