add null case and debugging