Fixed QR generation bug