two functions ported