Fix mean calculation