added middle_element method to give average of middle two elements in an even length array