fix bug on mapping and implement table_per_class mapping