Fixed array out of bounds when placing a flag