reference added for regexec while loop