fixed motion sensor code