Make histogram computation more idiomatic