implement recording function