Accelerometer function added