Added code for motion sensor