use preg_replace_callback for php 5.5 compatibility