algorithm for accelometer