with printing function