median Fix for Array indexing when avg is needed