instead of ``data[0]`` should this be ``for d in data: ...`` ?