Update api and add null checking