Changed frames.splice to frames.pop