must call close() as a function