fixed isOpen and added some comments