How planning ahead can help prevent migraines