modified close() method