changed to global function