Moved processAccelerationData into if statement, executes only if error is null.