fix array empty issues