fixed null-pointer bug