completed median calculations