slightly improve the rcm implementation