Move functions into module