Collecting data and creating a bar graph