6.1 GS working single target and AoE

This is my first time posting a macro and I hope that this works well for everyone. Feedback welcome as I am noob at this.

Talents: 3,3,1,1,2,1,2
glyphs: lightning shield, chain lightning, fire elemental

Hope this work well for everyone

Sequences["elest"] = {
StepFunction = [[
	limit = limit or 1
	if step == limit then
		limit = limit % #macros + 1
		step = 1
	else
		step = step % #macros + 1
	end
]],
PreMacro = 
[[
/targetenemy [noharm][dead]
/petattack [@target,harm]
]],
 '/castsequence reset=target Searing totem,Lightning Bolt,Lightning Bolt,Flame Shock,Lightning Bolt,Lightning Bolt,Lightning Bolt,Lightning Bolt,Lightning Bolt,Lightning Bolt,Earth Shock',
 '/castsequence [combat]reset=8 Lava Burst',
 '/castsequence [combat]reset=target !Flame Shock,null',
 '/castsequence [combat]reset=15 !Unleash Flame',
PostMacro = 
[[
/startattack
/use [combat]13
/use [combat]14
/run UIErrorsFrame:Clear()
]],
}

Sequences["eleaoe"] = {
StepFunction = [[
	limit = limit or 1
	if step == limit then
		limit = limit % #macros + 1
		step = 1
	else
		step = step % #macros + 1
	end
]],
PreMacro = 
[[
/targetenemy [noharm][dead]
/petattack [@target,harm]
]],
 '/castsequence reset=10 Earthquake,Searing Totem,Chain Lightning,Chain Lightning,Chain Lightning,Chain Lightning,Chain Lightning,Earth Shock',
}

I don’t have fire elemental in this macro as I like to cast that seperately. Also having problems in the code so searing totem doesn’t cancel it. So any help would be muchly appreciated. During tests in BRF LFR was pulling around 18k dps with an ILVL of 646.

I tried adding '/castsequence reset=target [nopet:Primal Fire Elemental] Searing Totem,Lightning Bolt… but for some reason spamming the [nopet:Primal Fire Elemental] makes my game crash…no idea how to solve this