fix Undefined offset: 0

check array key 0 exist