moved some functions into module