Optimize vhost_add function