moving code out from main into modules