Fixed boundary error bug - breaching memory