starting to coding the main function in the smc D version