#27 add close logic