fixed null ref bug