added function to average in reverse order and tried reverse count for flip function