Improve overflow logic