fix NULL pointer exception