use query instead of array access