added magnetometer code