mean and demeaned implemented