Fixed bug when finding and adding largest variables