added median, incomplete handling