Improving regex and update functions