refactored: stringLengthCheck function