length check added