move functions to module level