Added some bitwise to deal with the signed values