Fixed the Mode calculation