modified code for unsigned integers