added the open close function