Fix: change == to === for typed elements compare, and remove wrong length decrementation on out of array