Appeals court rules NSA's phone metadata collection program was illegal