This is the code part of the RGM on Github