delicate switch over action code from p001. Not sure which variables it is reading