moved some functions outside of class