better accelerometer code