fixed null pointer errors