Moved main function