Added generic factorial impl