Cleaner calculation of LCA algorithm