accelerometer rewrite