Finished histogram based calculation