functions moved as proposed