added function from file exchange #4605