add null check to avoid possible npe
remove unused private method