replace printf with visit as a more generic model