separate visgen function to visgen and visgen_base