changed temp.mean to temp.median in line 237