fix variable scoping for snake_array