Fix overflow calculation