Fixed array [number], made separate core method

Moved the main code to separate method and fixed the bug where [2] was
the 3rd point in the array because I realized [0] is array point 1 and
so on