works better if you loop through the data