add qr lib and fix bugs in model