further progress replicating the c-code