Dynamic Frame Slotted ALOHA (DFSA) is a de facto algorithm in the EPC Global Class-1 Generation-2 protocol for Radio Frequency Identification (RFID) tag collision problem. DFSA fails when the UHF RFID tag deployment becomes dense like in Internet of Things (IoT). Existing works do not provide readers prior tag estimates. Most algorithms assume a collision slot means two tag collision. But in dense IoT applications, much more than two tags can constitute a collision slot. Moreover, research proves collision slot might occur due to other reasons such as error-prone channel. This paper proposes a RFID anti-collision algorithm, kg-DFSA that equips the reader with prior information on accurate tag estimate. In kg-DFSA, tag identification is divided into two stages -initialization and identification. In the initialization stage, the reader uses improved K-means clustering running concurrently with a tag counter algorithm to cluster tags into K groups using tags' RN16 while the counter returns an accurate tag number estimate. In the identification stage, the tags are read only in frame chunks that match their group IDs while a new frame size look up table is developed to boost efficiency. Variants of the proposed kg-DFSA, traditional DFSA and another grouping based DFSA algorithm (FCM-DFSA) were implemented in MATLAB. Extensive Monte Carlo simulation shows the proposed kg-DFSA edges DFSA in terms of success rate 50%, system efficiency 65% and identification time 28%. The proposed model is useful in enhancing the existing MAC protocol to support dense IoT deployment of RFID.INDEX TERMS Dynamic frame slotted aloha, Internet of Things, k-means clustering, RFID anti-collision algorithm, tag grouping, frame size table.