improve api
fix null-pointer