implement the main code