errors everywhere
found one bitpos off by 1 error