Added missing check for null repository