accelerometer alg (not tested)