fixed null pointer errors.