extract rename as a standalone lib that can be used by others