re-factored the onSensorChanged() Method

To avoid any type of exception, onSensorChanged() Method is re-factored.