removed wrong include
improved checker of opened state