Calculates the mode