Add NULL check on open