An Improved Algorithm for On-Chip Clustering and Lossless Data Compression of HL-LHC Pixel Hits