improve logic for exceed error