Move functions and add doc