move functions away from global scope