Fix null/empty checking