corrected logic for weight sorter