rewrite the fromList function without using uncurry