Bug fix for NPE