modified factorial class