Added accelerometer logic