check for array before using array functions