moved validateLength method