Added new condition to avoid problems with empty reference field