fix to close correctly