It would be easier if you can give us your international and domestic airlines, different airlines are supposed to let you alight at different terminals and each might have a different terminal for immigration and customs. Even on separate tickets, airlines might have interline agreement, to have your luggage tagged all the way.
2hrs and 40 mins quite risky IMO. I've went through within 15 minutes (United terminal CBP, US resident line, no check in luggage). I've also had luggage delayed (ie additional inspection) with long long line at customs (more than 1 hr to clear all). Sometimes you reach the immigration with very short queue, other times, you reach there with a very long queue already waiting. In addition to those, you should also cater for minor delays (up to 30 minutes) from your international flight. After clearing immigration and customs, you will then have to re-clear security to get into the terminal for domestic flight, which can have long lines for the general line.
That said, 2hrs and 40mins would be ridding on your luck. If other flights happen to be delayed / earlier such that they are just slightly in front of you, then immigration and customs would be packs, so might the delivery of luggages. Similarly, sometimes the airline's own terminal may be full or down and they direct you to another terminal / international terminal to clear immigration and customs.