first part of the motion sensor