Moved some functions outside of the class