separate main function with completion function