Fix NPE bug by handling null display case