organizing code in main for mor order