replacing preg_replace with preg_replace_callback