made the mode function even more compact