Java Exception handled + remove duplicate/empty targets