Finished meaty portion of sensor code