simplified some logic when no length is found