Fix NPE problem