add null edge cases and handle them properly