selects middle spot first
changed loop for ending
modified variable