added retainOpen functionality.