return an empty array if ids is null
check length