sample has been changed to use auto factory