fixed broken length check