Main program loop