add main function for run in command line and format code