fixed a bug in factorial example
added some fixes