-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
-       
-               if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
-                 return DESCRIPTOR_SEARCH_Found;
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
+
+               /* Check the endpoint type, break out if correct BULK or INTERRUPT type endpoint found */
+               if (((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK) ||
+                   ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT))
+               {
+                       return DESCRIPTOR_SEARCH_Found;
+               }