Added number of frames as parameter