Fixed check for empty array