Precalculating before iterating, changing regex to be more robust, changing double quotes to single quotes around strings