Reading the motion detect status 

The function getXPosMotionDetected, used to read the motion status earlier returned bit values in the register  MPU6050_RA_MOT_DETECT_STATUS , a register which erases itself automatically after the register is read once. Therefore every time a bit value is read the rest of the register is cleared. Inorder to detect motion in all three axes, the entire register (the necessary 6 bits in that register) has to be read altogether. i have included a function uint_8 getMotionStatus() which returns the required six bits of the MPU6050_RA_MOT_DETECT_STATUS register. 
The function returns a uint_8 variable whose 0th bit would be the value of the ZPosMotionDetected status, the first one being ZNegMotionDetected status, then YPos and then YNeg and XPos and finally XNeg as is said in the datasheet