Cognitive relays form a special cooperation relationship among users in cognitive radio networks, and help increase the transmission rates of both primary users and secondary users. However, we observe that in certain scenarios, the use of relays may deteriorate the performance. In this paper, we propose a novel scheme in the MAC layer, called CodeAssist, by using network coding. It renders every relayed packet useful and recoverable as long as a sufficient number of coded packets are received by the intended terminal. CodeAssist is designed to apply network coding in every relay buffer, and moreover, leads to a lower bound of relayed packets for each secondary user. We also show numerical results for further demonstrations of the improved performance with CodeAssist. Categories and Subject Descriptors C.2.4 [Computer-Communication Networks]: Distributed Systems—Distributed Applications; C.4 [Performance of Systems]: Design Studies General Terms Algorithms, Design, Performance