integrated recording and looping code