Organizing main into functions