Fix rmab function