The main code of the FM
