Added key frame code