The logic got reversed. You want to check length > 0, right?