Added length != 0 condition