fixed bit shifts by using unsigned char so the negative bit doesn't screw things up