Routine to store position to array