Refactored surrogate building to use visitor pattern with return value