Latest imp code
Better empty array detection