Improve length constraint checks