Bug fix for null pointer exception