bug fixing for stream leak introduced by my last fix