Turn list printing into function