added code for motion sensor