replace numbers with variables much more efficiently