fix potential overflow