added a fix for the closing