Beginning frame generation code