added recording function