add new function from Gavin