Got factorial function working