Added implementation of mean function