added null checks for mDelegate