prevent oob array reads
formatting
inequalities for length checking
len caching
remove empty array test