added function to close rmf