more magnetic handling code