move qr generation to qr function