Replaced preg_replace with preg_replace_callback