Take out repetable code into get_array method