add open and close functionality