add some function stolen from org