make sure state isnt null