modified sensor part to fix some bugs