added new data and separated helper functions from algorithm