changed method of getting first element of array