array boundary checking