Weighing algorithm