only checking the length parameters to avoid infinite loop