redo im_rank() as a class