Moved avgClose function.