change condition to use length