Fix overflow bug