Move main functionality to its own file