Add better recording function