split functions out of main for modularity