Array boundary bug fixed