Working accelerometer script