moving code out of main